const express = require("express");
const path = require("path");
const bodyParser = require("body-parser");
let app = new express();
app.get("/", (req, res) => {
  res.sendFile(path.join(__dirname, "./views/index.html"));
});
app.use(bodyParser.json());

app.post("/postData", (req, res) => {
  let { type } = req.body;
  if (type === 1) {
    res.json({
      name: "zhangsan",
      age: 18,
    });
  } else if (type === 0) {
    res.json({
      name: "lisi",
      age: 20,
    });
  }
});

app.listen(8989);
